home *** CD-ROM | disk | FTP | other *** search
/ Champak 120 / Vol 120.iso / games / titans / beastboy.swf / scripts / frame_5 / DoAction.as
Text File  |  2010-11-09  |  5KB  |  220 lines

  1. movieclip.prototype.bulletlaunch = function(tipe, bulletrange)
  2. {
  3.    if(tipe <= 2)
  4.    {
  5.       m.attachmovie("sbul1","e" + r.ed,r.ed);
  6.       m["e" + r.ed].delay = bulletrange;
  7.       m["e" + r.ed]._x = this._x;
  8.       if(tipe == 2)
  9.       {
  10.          m["e" + r.ed]._yscale = -100;
  11.          m["e" + r.ed]._y = this._y - 40;
  12.       }
  13.       else
  14.       {
  15.          m["e" + r.ed]._y = this._y + 40;
  16.       }
  17.    }
  18.    else if(tipe > 2 and tipe < 5)
  19.    {
  20.       m.attachmovie("sbul2","e" + r.ed,r.ed);
  21.       m["e" + r.ed].delay = bulletrange;
  22.       m["e" + r.ed]._y = this._y;
  23.       if(tipe == 3)
  24.       {
  25.          m["e" + r.ed]._xscale = -100;
  26.          m["e" + r.ed]._x = this._x + 35;
  27.       }
  28.       else
  29.       {
  30.          m["e" + r.ed]._x = this._x - 35;
  31.       }
  32.    }
  33.    else if(tipe > 4 and tipe < 7)
  34.    {
  35.       m.attachmovie("sbul2","e" + r.ed,r.ed);
  36.       m["e" + r.ed].delay = 100;
  37.       m["e" + r.ed]._y = this._y - 44;
  38.       if(tipe == 5)
  39.       {
  40.          m["e" + r.ed]._xscale = -100;
  41.          m["e" + r.ed]._x = this._x + 40;
  42.       }
  43.       else
  44.       {
  45.          m["e" + r.ed]._x = this._x - 40;
  46.       }
  47.    }
  48.    r.ed = r.ed + 1;
  49. };
  50. movieclip.prototype.cekhitp = function(it)
  51. {
  52.    if(p.z.hittest(it))
  53.    {
  54.       r.hit = 1;
  55.       if(p._x - this._x < 0)
  56.       {
  57.          r.hitdir = 1;
  58.       }
  59.       else
  60.       {
  61.          r.hitdir = 2;
  62.       }
  63.       return true;
  64.    }
  65.    return false;
  66. };
  67. movieclip.prototype.cekhitattack = function(it)
  68. {
  69.    if(p.z.hittest(it))
  70.    {
  71.       if(r.pnow == 2 and r.jump and math.abs(r.xs) > 3)
  72.       {
  73.          this.die = 1;
  74.          return false;
  75.       }
  76.       if(p._x - this._x < 0)
  77.       {
  78.          r.hitdir = 1;
  79.       }
  80.       else
  81.       {
  82.          r.hitdir = 2;
  83.       }
  84.       r.hit = 1;
  85.       return true;
  86.    }
  87.    return false;
  88. };
  89. movieclip.prototype.cekboxcoll = function(ex, ey, ew, eh, sx, sy, sw, sh)
  90. {
  91.    var res = 0;
  92.    if(math.abs(ex - sx) < ew + sw)
  93.    {
  94.       if(ey - sy >= 0 and ey - sy <= eh or sy - ey >= 0 and sy - ey <= sh)
  95.       {
  96.          res = 1;
  97.       }
  98.    }
  99.    return res;
  100. };
  101. Movieclip.prototype.initb = function()
  102. {
  103.    if(!this.tipe)
  104.    {
  105.       var tipe = 0;
  106.    }
  107.    else
  108.    {
  109.       var tipe = this.tipe;
  110.    }
  111.    var wi = this.z._width * 0.01 * this._xscale;
  112.    var hi = this.z._height * 0.01 * this._yscale;
  113.    if(tipe == 2)
  114.    {
  115.       if(this.xs > 0)
  116.       {
  117.          var xmi = this._x;
  118.          var xma = this._x + math.abs(this.xrange);
  119.       }
  120.       else if(this.xs < 0)
  121.       {
  122.          var xmi = this._x - math.abs(this.xrange);
  123.          var xma = this._x;
  124.       }
  125.       if(this.ys > 0)
  126.       {
  127.          var ymi = this._y;
  128.          var yma = this._y + math.abs(this.yrange);
  129.       }
  130.       else if(this.ys < 0)
  131.       {
  132.          trasce(fsd);
  133.          var ymi = this._y - math.abs(this.yrange);
  134.          var yma = this._y;
  135.       }
  136.       c.push({n:this._name,t:tipe,w:wi,h:hi,x1:this._x,y1:this._y,x2:this._x + wi,y2:this._y + hi,xc:this._x + 0.5 * wi,xs:this.xs,ys:this.ys,xmin:xmi,xmax:xma,ymin:ymi,ymax:yma});
  137.    }
  138.    else
  139.    {
  140.       b.push({n:this._name,t:tipe,w:wi,h:hi,x1:this._x,y1:this._y,x2:this._x + wi,y2:this._y + hi,xc:this._x + 0.5 * wi});
  141.    }
  142. };
  143. Array.prototype.removeElement = function(i)
  144. {
  145.    if(i == null)
  146.    {
  147.       i = 0;
  148.    }
  149.    var r = this[i];
  150.    var j = i;
  151.    while(j < this.length - 1)
  152.    {
  153.       this[j] = this[j + 1];
  154.       j++;
  155.    }
  156.    this.pop();
  157.    return r;
  158. };
  159. Array.prototype.removeValue = function(a)
  160. {
  161.    var i = 0;
  162.    while(i < this.length)
  163.    {
  164.       if(a == this[i])
  165.       {
  166.          this.removeElement(i);
  167.       }
  168.       i++;
  169.    }
  170. };
  171. Movieclip.prototype.fadescreen = function(speed)
  172. {
  173.    if(!speed)
  174.    {
  175.       var speed = 5;
  176.    }
  177.    _root.createemptymovieclip("dark",100001);
  178.    var d = _root.dark;
  179.    with(d)
  180.    {
  181.       lineStyle(1,0,100);
  182.       beginfill(0,100);
  183.       moveto(-5000,-5000);
  184.       lineto(5000,-5000);
  185.       lineto(5000,5000);
  186.       lineto(-5000,5000);
  187.       endfill();
  188.       d.onEnterFrame = function()
  189.       {
  190.          _alpha -= speed;
  191.          if(_alpha <= 0)
  192.          {
  193.             removeMovieClip("");
  194.             stop();
  195.          }
  196.       };
  197.    }
  198. };
  199. Color.prototype.setBrightness = function(value)
  200. {
  201.    this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
  202.    var trans = this.getTransform();
  203.    var percent = Math.abs(value) / 100;
  204.    var brightnessColor = value <= 0 ? 0 : 255;
  205.    with(trans)
  206.    {
  207.       ra -= ra * percent;
  208.       ga -= ga * percent;
  209.       ba -= ba * percent;
  210.       rb += (brightnessColor - rb) * percent;
  211.       gb += (brightnessColor - gb) * percent;
  212.       bb += (brightnessColor - bb) * percent;
  213.    }
  214.    this.setTransform(trans);
  215. };
  216. Color.prototype.resetcolor = function()
  217. {
  218.    this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
  219. };
  220.